<template>
	<view class="">
		<button @click="connect">connect</button>
	</view>
</template>

<script setup>
	const connect = async () => {
		
		let publicKey = ''
		await 
		uni.request({
			url: 'http://192.168.1.115:3000/deeplink', //仅为示例，并非真实接口地址。
			data: {
				text: 'uni.request'
			},
			header: {
				'custom-header': 'hello' //自定义请求头信息
			},
			success: (res) => {
				const {privateKey} = res.data.data
				publicKey = res.data.data.publicKey
				
				uni.setStorageSync('privateKey',privateKey)
				uni.setStorageSync('publicKey',publicKey)
				
				console.log(publicKey,'publicKey');
				
				const appUrl = encodeURIComponent("http://cxc.firo.asia/#/"); // 用您的应用 URL 替换
				// const appUrl = encodeURIComponent("https://phantom.app"); // 用您的应用 URL 替换
				const encryptionPublicKey = publicKey; // 替换为您的加密公钥
				const redirectLink = encodeURIComponent("hbuilder://pages/index/index"); // 用您的回调 URL 替换
				
				const phantomUrl =
					`https://phantom.app/ul/v1/connect?app_url=${appUrl}&dapp_encryption_public_key=${encryptionPublicKey}&redirect_link=${redirectLink}`;
				plus.runtime.openURL(phantomUrl); // 打开 Phantom 钱包进行连接
			}
		});




	}
</script>

<style>
	.content {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.logo {
		height: 200rpx;
		width: 200rpx;
		margin-top: 200rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 50rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>